﻿namespace TelecoSystems.Web.Models
{
    using System;
    using System.ComponentModel.DataAnnotations;
    using System.Data.Objects.DataClasses;
    using System.ServiceModel.DomainServices;

    // The MetadataTypeAttribute identifies ProductMetadata as the class
    // that carries additional metadata for the Product class.
    [MetadataTypeAttribute(typeof(Product.ProductMetadata))]
    public partial class Product
    {

        // This class allows you to attach custom attributes to properties
        // of the Product class.
        //
        // For example, the following marks the Xyz property as a
        // required property and specifies the format for valid values:
        //    [Required]
        //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
        //    [StringLength(32)]
        //    public string Xyz { get; set; }
        internal sealed class ProductMetadata
        {
            // Metadata classes are not meant to be instantiated.
            private ProductMetadata()
            {
            }

            [Editable(false)]
            public int Id { get; set; }

            [Required]
            [StringLength(20)]
            [Display(Name = "Product name", Description = "The name of the product family.")]            
            public string Name { get; set; }

            [Required]
            [StringLength(200)]
            [Display(Description = "Short description of the product family.")]
            public string Description { get; set; }

            [Editable(false)]
            [Display(AutoGenerateField = false)]
            public Guid CreatorID { get; set; }

            [Editable(false)]
            [Display(Name = "Created", Description = "Date when the record was created.")]
            public DateTime DateCreated { get; set; }

            [Editable(false)]
            [Display(Name = "Modified", Description = "Date of the last modification.")]
            public DateTime DateLastModified { get; set; }

            [Display(AutoGenerateField = false)]
            public byte[] Image { get; set; }

            [ExternalReference]
            [Association("ProductVariant", "Id", "ProductID")]
            public EntityCollection<Variant> Variants { get; set; }
        }
    }
}
